<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数式组件</title>
    <style>
        header{
            height: 100px;
            background: #aef;
        }

        section{
            height: 400px;
            background: rgb(42, 88, 19);
        }

        footer{
            height: 100px;
            background: #c65;
        }
    </style>
</head>
<body>
    <div id="root"></div>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">

        //函数式组件  函数名称首字母一定要大写
        function Top(){
            return <header>头部区域</header>;
        }

        //内容区
        function Main(){
            return <section>内容区域</section>
        }

        //底部
        function Bottom(){
            return <footer>尾部区域</footer>
        }


        //创建虚拟 DOM 对象    Top  内部会调用 Top 函数, 然后返回虚拟 DOM 对象
        // let vDOM = <div>
        //         <Top></Top>
        //         <Main />
        //         <Bottom></Bottom>
        //     </div>;
        
        //封装组件
        function App(){
            return <div>
                <Top></Top>
                <Main />
                <Bottom></Bottom>
            </div>;
        }

        //渲染 App() X
        ReactDOM.render(<App />, document.querySelector("#root"));

    </script>
</body>
</html>